package com.cn.dtalk.util;

import com.alibaba.fastjson.JSON;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.ContentType;

import java.io.IOException;
import java.util.Map;

/**
 * @author: WGQ
 * @data: 2020/10/23 9:18
 * @desc:
 */
public class HttpUtil {

    /**
     * http send post request
     * @param url
     * @param message
     * @return
     */
    public String send(String url, Message message) {
        try {
            return Request.Post(url).connectTimeout(8000)
                    .bodyString(JSON.toJSONString(message), ContentType.APPLICATION_JSON)
                    .execute()
                    .returnContent()
                    .asString();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }

    }
}
